package org.rc.dto;

import lombok.Data;
import org.rc.entity.Role;
import org.rc.entity.User;

import java.util.List;

@Data
public class UserPageRes {

    private Long id;

    private String name;

    private String loginName;

    private String phoneNo;

    private String post;

    private Integer gender;

    private List<RoleInfo> roles;

    @Data
    public static class RoleInfo{
        private Long id;

        private String name;

        public static RoleInfo getInstance(Role role){
            RoleInfo roleInfo = new RoleInfo();
            roleInfo.setId(role.getId());
            roleInfo.setName(role.getName());
            return roleInfo;
        }
    }

    public static UserPageRes getInstance(User user){
        UserPageRes userPageRes = new UserPageRes();
        userPageRes.setId(user.getId());
        userPageRes.setName(user.getName());
        userPageRes.setPhoneNo(user.getPhoneNo());
        userPageRes.setGender(user.getGender());
        userPageRes.setPost(user.getPost());
        userPageRes.setLoginName(user.getLoginName());
        return userPageRes;
    }
}
